package com.morphiastic.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;



/**
 * annotation used to work with a map and specifying how key and value should be
 * analyzed and indexed 
 * 
 * 
 * If the Map to index contains nested Maps it is better to use manual index definition
 * or the future ElastiManual annotation where we will be able to add JSON like
 * definition for the field indexation def
 * @author Alex
 */

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.FIELD })
@Documented
public @interface ElastiMap {
	
	
	/**
	 * @return Returns the field name as it will appear in the index. Defaults to the JavaBean property name.
	 */
	String name() default "";
	
	ElastiField keyAnnotation() default @ElastiField(name="key");
	ElastiField valueAnnotation() default @ElastiField(name="value");
	
	int circularRefMaxDepth() default 3;
	
	
	/**
	 * Annotations used if we want the key or value of the map to be treated as embedded fields
	 * The default circularRefMaxDepth value of -1 indicates that t is not used and that we will 
	 * use the ElastiField keyAnnotation or valueAnnotation instead
	 * to generate the mapping.
	 * 
	 * Be aware however that if there is no ElastiFieldEmbedded on a type that ElastiField cant support, an exception will be thrown 
	 * at startup / mapping generation time
	 * @return
	 */
	ElastiFieldEmbedded embeddedKeyAnnotation() default @ElastiFieldEmbedded(circularRefMaxDepth=-1);
	ElastiFieldEmbedded embeddedValueAnnotation() default @ElastiFieldEmbedded(circularRefMaxDepth=-1);
	
	
	 
	
	
}
